<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB R2019b"><title>Multi-Robot Lidar Sensor</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: left;  }
.S1 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }
.S2 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left;  }
.S3 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;  }
.S4 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S5 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S6 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S7 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S8 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 16.996px;  }
.embeddedOutputsErrorElement {min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
.embeddedOutputsWarningElement{min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
.diagnosticMessage-wrapper {font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {color: rgb(255,100,0); text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {color: rgb(230,0,0); text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {white-space: pre-wrap;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {white-space: pre;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {white-space: pre; word-wrap: initial; min-height: 18px; max-height: 250px; overflow: auto;}
.textElement,.rtcDataTipElement .textElement {padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {min-height: 16px;}
.rightPaneElement .textElement {padding-top: 2px; padding-left: 9px;}
.S9 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S10 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }</style></head><body><div class = rtcContent><h1  class = 'S0'><span>Multi-Robot Lidar Sensor</span></h1><div  class = 'S1'><span>Copyright 2019 The MathWorks, Inc.</span></div><h2  class = 'S2'><span>Overview</span></h2><div  class = 'S1'><span>The Multi-Robot Lidar Sensor allows you to simulate 2D line-of-sight sensors for visualization and algorithm prototyping of multi-robot environments. This sensor will test for line-of-sight with an occupancy map as well as other robots with finite radius in the environment. It includes a MATLAB and Simulink interface.</span></div><div  class = 'S1'><img class = "imageNode" src = "" width = "279" height = "299" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span style=' font-weight: bold;'>Properties:</span></div><ul  class = 'S3'><li  class = 'S4'><span style=' font-weight: bold;'>Map: </span><span>A </span><a href = "matlab: doc robotics.OccupancyGrid"><span style=' font-family: monospace;'>robotics.OccupancyGrid</span></a><span> or </span><a href = "matlab: doc robotics.BinaryOccupancyGrid"><span style=' font-family: monospace;'>robotics.BinaryOccupancyGrid</span></a></li><li  class = 'S4'><span style=' font-weight: bold;'>Sensor offset:</span><span> A 2-by-1 array of </span><span texencoding="[x; y]" style="vertical-align:-5px"><img src="" width="35.5" height="17.5" /></span><span> offset from the vehicle</span></li><li  class = 'S4'><span style=' font-weight: bold;'>Scan angles:</span><span> An N-by-1 array of scan angles about the </span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);">x</span><span>-axis, in radians</span></li><li  class = 'S4'><span style=' font-weight: bold;'>Maximum range:</span><span> The sensor maximum range, in meters. Any values outside this range return </span><span style=' font-family: monospace;'>NaN</span><span>. </span></li><li  class = 'S4'><span style=' font-weight: bold;'>Robot index:</span><span> The robot index, from 1 to number of robots N</span></li><li  class = 'S4'><span style=' font-weight: bold;'>Robot radii:</span><span> An N-by-1 array of robot radii, in meters (optional)</span></li></ul><div  class = 'S1'><span style=' font-weight: bold;'>Inputs:</span></div><div  class = 'S1'><span>You can attach a </span><span style=' font-family: monospace;'>MultiRobotEnv</span><span> object so this sensor can be used without inputs by probing into the state of the multi-robot environment. Otherwise, there are up to 2 optional inputs.</span></div><ul  class = 'S3'><li  class = 'S4'><span style=' font-weight: bold;'>Poses: </span><span>A 3-by-N array representing the robot poses </span><span texencoding="[x; y; \theta]" style="vertical-align:-5px"><img src="" width="50" height="17.5" /></span><span>, in meters and radians respectively</span></li><li  class = 'S4'><span style=' font-weight: bold;'>Robot radii:</span><span> An N-by-1 array of robot radii, in meters (if the property is left at its default of -1)</span></li></ul><div  class = 'S1'><span style=' font-weight: bold;'>Outputs:</span></div><ul  class = 'S3'><li  class = 'S4'><span style=' font-weight: bold;'>Ranges: </span><span>An N-by-1 array of ranges, in meters, corresponding to the </span><span style=' font-weight: bold;'>Scan angles</span><span> property.</span></li></ul><h2  class = 'S2'><span>MATLAB Usage</span></h2><div  class = 'S1'><span>Create a </span><span style=' font-family: monospace;'>MultiRobotLidarSensor</span><span> object, set it to a robot index of 3, and configure other sensor properties.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S5'><span style="white-space: pre;"><span>lidar = MultiRobotLidarSensor;</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>lidar.robotIdx = 3;</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>lidar.sensorOffset = [0,0];</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>lidar.scanAngles = linspace(-pi/2,pi/2,21); </span><span style="color: rgb(60, 118, 61);">% 21 scans from -pi/2 to +pi/2</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>lidar.maxRange = 4</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput" uid="DC791100" data-testid="output_0" data-width="428" data-height="135" data-hashorizontaloverflow="true" style="width: 458px; max-height: 261px;"><div class="textElement"><div><span class="variableNameElement">lidar = </span></div><div>  MultiRobotLidarSensor with properties:

         mapName: ''
    sensorOffset: [0 0]
      scanAngles: [-1.5708 -1.4137 -1.2566 -1.0996 -0.9425 -0.7854 -0.6283 -0.4712 -0.3142 -0.1571 0 0.1571 0.3142 0.4712 0.6283 0.7854 0.9425 1.0996 1.2566 1.4137 1.5708]
        maxRange: 4
        robotIdx: 3
      robotRadii: -1
</div></div></div></div></div></div><div  class = 'S1'><span>Attach the sensor to a 5-robot environment. The environment contains an example map and all robot radii are 0.5 meters.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S5'><span style="white-space: pre;"><span>numRobots = 5;</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>env = MultiRobotEnv(numRobots);</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>load </span><span style="color: rgb(160, 32, 240);">exampleMap</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>env.mapName = </span><span style="color: rgb(160, 32, 240);">'map'</span><span>;</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>env.robotRadius = 0.5*ones(5,1);</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>env.hasWaypoints = false;</span></span></div></div><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>attachLidarSensor(env,lidar);</span></span></div></div></div><div  class = 'S1'><span>Simulate the lidar and plot the ranges given the map and vehicle pose.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S5'><span style="white-space: pre;"><span>env.Poses = [1 1 0;2 2 0;3 3 0;4 4 0;5 5 0]';</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>ranges = lidar();</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>plot(lidar.scanAngles,ranges,</span><span style="color: rgb(160, 32, 240);">'bo-'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>xlabel(</span><span style="color: rgb(160, 32, 240);">'Angle [rad]'</span><span>)</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>ylabel(</span><span style="color: rgb(160, 32, 240);">'Range [m]'</span><span>)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="A07DBAB1" data-testid="output_1" style="width: 458px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 560px;"></div></div></div></div></div><div  class = 'S1'><span>Visualize using the Multi-Robot Visualizer.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S5'><span style="white-space: pre;"><span>allRanges = cell(1,numRobots);</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>allRanges{3} = ranges;</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>env(1:numRobots,env.Poses,allRanges)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="9C8EE0D5" data-testid="output_2" style="width: 458px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 560px;"></div></div></div></div></div><div  class = 'S10'><span style=' font-weight: bold;'>Examples</span></div><ul  class = 'S3'><li  class = 'S4'><a href = "matlab:edit mrsMultiRobotLidar"><span>Multirobot lidar sensor MATLAB example</span></a></li></ul><h2  class = 'S2'><span>Simulink Usage</span></h2><div  class = 'S1'><span>Use the </span><span style=' font-weight: bold;'>Multi-Robot Lidar Sensor</span><span> block from the </span><span style=' font-weight: bold;'>Environments</span><span> section of the </span><a href = "matlab:mobileRoboticsLib"><span>block library</span></a><span>. </span></div><div  class = 'S1'><img class = "imageNode" src = "" width = "760" height = "394" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><img class = "imageNode" src = "" width = "794" height = "471" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span style=' font-weight: bold;'>Examples</span></div><ul  class = 'S3'><li  class = 'S4'><a href = "matlab:mrsMultiRobotSensorModel"><span>Multi-Robot Sensor Example</span></a></li><li  class = 'S4'><a href = "matlab:mrsMultiRobotAvoidance"><span>Multi-Robot Obstacle Avoidance Example</span></a></li></ul></div>
<br>
<!-- 
##### SOURCE BEGIN #####
%% Multi-Robot Lidar Sensor
% Copyright 2019 The MathWorks, Inc.
%% Overview
% The Multi-Robot Lidar Sensor allows you to simulate 2D line-of-sight sensors 
% for visualization and algorithm prototyping of multi-robot environments. This 
% sensor will test for line-of-sight with an occupancy map as well as other robots 
% with finite radius in the environment. It includes a MATLAB and Simulink interface.
% 
% 
% 
% *Properties:*
%% 
% * *Map:* A <matlab: doc robotics.OccupancyGrid |robotics.OccupancyGrid|> or 
% <matlab: doc robotics.BinaryOccupancyGrid |robotics.BinaryOccupancyGrid|>
% * *Sensor offset:* A 2-by-1 array of $[x; y]$ offset from the vehicle
% * *Scan angles:* An N-by-1 array of scan angles about the $x$-axis, in radians
% * *Maximum range:* The sensor maximum range, in meters. Any values outside 
% this range return |NaN|. 
% * *Robot index:* The robot index, from 1 to number of robots N
% * *Robot radii:* An N-by-1 array of robot radii, in meters (optional)
%% 
% *Inputs:*
% 
% You can attach a |MultiRobotEnv| object so this sensor can be used without 
% inputs by probing into the state of the multi-robot environment. Otherwise, 
% there are up to 2 optional inputs.
%% 
% * *Poses:* A 3-by-N array representing the robot poses $[x; y; \theta]$, in 
% meters and radians respectively
% * *Robot radii:* An N-by-1 array of robot radii, in meters (if the property 
% is left at its default of -1)
%% 
% *Outputs:*
%% 
% * *Ranges:* An N-by-1 array of ranges, in meters, corresponding to the *Scan 
% angles* property.
%% MATLAB Usage
% Create a |MultiRobotLidarSensor| object, set it to a robot index of 3, and 
% configure other sensor properties.

lidar = MultiRobotLidarSensor;
lidar.robotIdx = 3;
lidar.sensorOffset = [0,0];
lidar.scanAngles = linspace(-pi/2,pi/2,21); % 21 scans from -pi/2 to +pi/2
lidar.maxRange = 4
%% 
% Attach the sensor to a 5-robot environment. The environment contains an example 
% map and all robot radii are 0.5 meters.

numRobots = 5;
env = MultiRobotEnv(numRobots);
load exampleMap
env.mapName = 'map';
env.robotRadius = 0.5*ones(5,1);
env.hasWaypoints = false;
attachLidarSensor(env,lidar);
%% 
% Simulate the lidar and plot the ranges given the map and vehicle pose.

env.Poses = [1 1 0;2 2 0;3 3 0;4 4 0;5 5 0]';
ranges = lidar();
plot(lidar.scanAngles,ranges,'bo-');
xlabel('Angle [rad]')
ylabel('Range [m]')
%% 
% Visualize using the Multi-Robot Visualizer.

allRanges = cell(1,numRobots);
allRanges{3} = ranges;
env(1:numRobots,env.Poses,allRanges)
%% 
% *Examples*
%% 
% * <matlab:edit mrsMultiRobotLidar Multirobot lidar sensor MATLAB example>
%% Simulink Usage
% Use the *Multi-Robot Lidar Sensor* block from the *Environments* section of 
% the <matlab:mobileRoboticsLib block library>. 
% 
% 
% 
% 
% 
% *Examples*
%% 
% * <matlab:mrsMultiRobotSensorModel Multi-Robot Sensor Example>
% * <matlab:mrsMultiRobotAvoidance Multi-Robot Obstacle Avoidance Example>
##### SOURCE END #####
--></body></html>